<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <canvas id="web" style="background-color: blue;"></canvas>
    <script id="vertexShader" type="x-shader/x-vertex">
        void main(){
            gl_PointSize = 20.0;
            gl_Position= vec4(0.0, 0.0,0.0, 1.0);
        }
    </script>
    <script id="fragmentShader" type="x-shader/x-frament">
        void main(){
            gl_FragColor = vec4(1.0,0.0,0.0,1.0);
        }
    </script>
        
    <script>
        const initShader = (gl, vertexShadeSource, fragmentShadeSource) =>{
            let vertexShader = gl.createShader(gl.VERTEX_SHADER);
            let framentShader = gl.createShader(gl.FRAGMENT_SHADER);
            gl.shaderSource(vertexShader, vertexShadeSource);
            gl.shaderSource(framentShader, fragmentShadeSource);
            gl.compileShader(vertexShader);
            gl.compileShader(framentShader);

            let program = gl.createProgram();
            gl.attachShader(program, vertexShader);
            gl.attachShader(program, framentShader);
            gl.linkProgram(program);
            gl.useProgram(program);
            return program;
        }

        let canvas = document.getElementById('web');
        let gl = canvas.getContext('webgl');
        let vertexShadeSource = document.getElementById("vertexShader").innerText;
        let fragmentShadeSource = document.getElementById('fragmentShader').innerText;
        let program = initShader(gl, vertexShadeSource, fragmentShadeSource);
        gl.drawArrays(gl.POINTS, 0, 1);
        
    </script>
</body>
</html>